/*
 * #%L
 * java model
 * %%
 * Copyright (C) 2009 - 2011 Stefan Isele
 * %%
 * All Rights Reserved.
 * This program is dual-licensed under the GNU General Public license
 * or a commercial license.
 * You may select to use one or the other of these licenses.
 * To obtain a commercial license please contact Stefan Isele at www.stefan-isele.de
 * Any modifications to this file must keep this entire header intact.
 * Redistribution, except as permitted by the selected license, is prohibited.
 * #L%
 */
package com.prefabware.jmodel;

import java.util.ArrayList;
import java.util.List;

/**
 * to reference a type
 * a type reference contains the raw type and the type arguments
 * @author sisele_job
 *
 */
public class JTypeRef {
	private JType type;
	private List<JType> typeArguments;

	public JTypeRef(JType type) {
		super();
		this.type = type;
		this.typeArguments = new ArrayList<JType>();
	}

	public JType getType() {
		return type;
	}

	public List<JType> getTypeArguments() {
		return typeArguments;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((type == null) ? 0 : type.hashCode());
		result = prime * result
				+ ((typeArguments == null) ? 0 : typeArguments.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		JTypeRef other = (JTypeRef) obj;
		if (type == null) {
			if (other.type != null)
				return false;
		} else if (!type.equals(other.type))
			return false;
		if (typeArguments == null) {
			if (other.typeArguments != null)
				return false;
		} else if (!typeArguments.equals(other.typeArguments))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "JTypeRef [type=" + type + ", typeArguments=" + typeArguments
				+ "]";
	}
	
}
